package com.xumingxun.aibox.domain.condition;

import com.xumingxun.aibox.context.Context;
import com.xumingxun.aibox.domain.var.Var;
import com.xumingxun.aibox.enums.CompareEnum;
import lombok.Data;

@Data
public class Compare {
    Var var;
    CompareEnum compare;
    Object value;

    public boolean execute(Context context){
        if(compare==CompareEnum.CONTAIN){
            return String.valueOf(var.getValue()).contains(String.valueOf(value));
        }else if(compare==CompareEnum.NOTCONTAIN){
            return !String.valueOf(var.getValue()).contains(String.valueOf(value));
        }

        return true;
    }
}
